home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_005 / proctest / littleproc.c next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  94 lines

  1. /*
  2.  *
  3.  *    DISCLAIMER:
  4.  *
  5.  *    This program is provided as a service to the programmer
  6.  *    community to demonstrate one or more features of the Amiga
  7.  *    personal computer.  These code samples may be freely used
  8.  *    for commercial or noncommercial purposes.
  9.  * 
  10.  *     Commodore Electronics, Ltd ("Commodore") makes no
  11.  *    warranties, either expressed or implied, with respect
  12.  *    to the program described herein, its quality, performance,
  13.  *    merchantability, or fitness for any particular purpose.
  14.  *    This program is provided "as is" and the entire risk
  15.  *    as to its quality and performance is with the user.
  16.  *    Should the program prove defective following its
  17.  *    purchase, the user (and not the creator of the program,
  18.  *    Commodore, their distributors or their retailers)
  19.  *    assumes the entire cost of all necessary damages.  In 
  20.  *    no event will Commodore be liable for direct, indirect,
  21.  *    incidental or consequential damages resulting from any
  22.  *    defect in the program even if it has been advised of the 
  23.  *    possibility of such damages.  Some laws do not allow
  24.  *    the exclusion or limitation of implied warranties or
  25.  *    liabilities for incidental or consequential damages,
  26.  *    so the above limitation or exclusion may not apply.
  27.  *
  28.  */
  29.  
  30. /* sample slave code for create process test */
  31.  
  32. /* author: Rob Peck   1/4/86, using exec_support task functions.   */
  33.  
  34. /* system software version: V1.1               */
  35.  
  36. #include "exec/types.h"
  37. #include "exec/nodes.h"
  38. #include "exec/lists.h"
  39. #include "exec/libraries.h"
  40. #include "exec/ports.h"
  41. #include "exec/interrupts.h"
  42. #include "exec/io.h"
  43.  
  44. #include "libraries/dos.h"
  45. #include "libraries/dosextens.h"
  46.  
  47. #include "workbench/startup.h"
  48.  
  49. /* these are going to be supplied to the slave by the starter */
  50.  
  51. extern int stdout;
  52. extern int stderr;
  53.  
  54. struct mymess {
  55.    struct Message sysmess;
  56.    int outpointer;
  57.    int errpointer;
  58. };
  59.  
  60. extern struct Message *GetMsg();
  61. extern struct Task *FindTask();
  62.  
  63. main()
  64.     int type;            /* type of message received */
  65.     int waitforeverSignal;
  66.     struct mymess *msg;
  67.     struct MsgPort *myport;
  68.     struct Process *myprocess;
  69.  
  70.     myprocess = (struct Process *)FindTask(0);
  71.  
  72.     myport = &myprocess->pr_MsgPort;
  73.  
  74.     WaitPort(myport);    /* wait for starter to post a message. */
  75.                 /* Special sample message has his stderr, 
  76.                  * stdout so we can both post stuff to 
  77.                  * the same window */
  78.  
  79.     msg = (struct mymess *)GetMsg(myport);
  80.  
  81.     stdout = msg->outpointer;
  82.     stderr = msg->errpointer;
  83.     ReplyMsg(msg);
  84.  
  85.     /* use printf to prove that it is really a process... a task
  86.      * cannot do this without crashing */
  87.  
  88.     printf("\nHere I am, that slave task you started!!!  bye!");
  89.     
  90. }    /* now simply fall off the end of the world, should return cleanly */    
  91.  
  92.     
  93.